package com.sts.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sts.bean.User;

@Repository
public class UserDao implements IUserDao {

	
	@Resource
	private SqlSessionFactory sqlSessionFactory;
	
	Logger log = Logger.getLogger(this.getClass());
	
	
	@Override
	public int insertUser(User user) {
		int result = 0;
		SqlSession session = sqlSessionFactory.openSession();
		IUserDao Iuser = session.getMapper(IUserDao.class);
		result = Iuser.insertUser(user) ;
		return result;
	}

	@Override
	public User selectUser(Map<String,Object> map) {
		SqlSession session = sqlSessionFactory.openSession();
		IUserDao Iuser = session.getMapper(IUserDao.class);
		User user = Iuser.selectUser(map);
		
		return user;
	}

	@Override
	public List<User> selectUserList(Map<String,Object> map) {
		List<User> list = new ArrayList<User>() ;
		SqlSession session = sqlSessionFactory.openSession();
		IUserDao Iuser = session.getMapper(IUserDao.class);
		list = Iuser.selectUserList(map) ;
		return null;
	}

	@Override
	public int deleteUser(String id) {
		SqlSession session = sqlSessionFactory.openSession();
		IUserDao Iuser = session.getMapper(IUserDao.class);
		int result = Iuser.deleteUser(id) ;
				
		return result;
	}

	@Override
	public int selectSize(Map<String,Object> map) {
		
		SqlSession session = sqlSessionFactory.openSession();
		IUserDao Iuser = session.getMapper(IUserDao.class);
		int result = Iuser.selectSize(map) ;
		
		
		return result;
	}

}
